CC = g++ -O3 -Wall
CFLAG = -c 
IFLAG = -I./App \
	-I./Test \
	-I./Geometry \
	-I./Common \
	-I./Solver


LIBFlAG = -shared -fPIC


EXECUTABLE = CGKS
TESTEXECUTABLE = test
INCLUDE_DIRECTORY = ./Test/ \
					./App \
					./Geometry \
					./Common \
					./Solver

APP_SRCS = ./App/CGKS.cpp 
TEST_SRCS = ./App/Test.cpp ./Test/CTest.cpp \

APP_OBJS = $(APP_SRCS:.cpp=.o)
TEST_OBJS = $(TEST_SRCS:.cpp=.o)

LIBCFG_SRCS = ./Common/CConfig.cpp

LIBGEO_SRCS = ./Geometry/CEntity.cpp  \
			  ./Geometry/CGeometry.cpp

LIBSOLVER_SRCS = ./Solver/CSolver.cpp 
LIBOUTPUT_SRCS = ./solver/COutput.cpp

LIBS = libgeo.so libsolver.so libcfg.so


$(EXECUTABLE) : $(APP_OBJS) $(LIBS)
	$(CC) $^  -Wl,--rpath=. -L . -o $@ $(IFLAG) 

$(TESTEXECUTABLE) : $(TEST_OBJS) $(LIBS)
	$(CC) $^  -Wl,--rpath=. -L . -o $@ $(IFLAG) 

%.o : %.cpp
	$(CC) $(CFLAG) $< -o $@ $(IFLAG)

libgeo.so : $(LIBGEO_SRCS)
	$(CC) $(LIBFlAG) $^ -o $@ $(IFLAG)

libsolver.so : $(LIBSOLVER_SRCS)
	$(CC) $(LIBFlAG) $^ -o $@ $(IFLAG)

liboutput.so : $(LIBOUTPUT_SRCS)
	$(CC) $(LIBFlAG) $^ -o $@ $(IFLAG)

libcfg.so : $(LIBCFG_SRCS)
	$(CC) $(LIBFlAG) $^ -o $@ $(IFLAG)


.PHONY:

clean:
	-rm -f ./App/*.o
	-rm -f ./App/.*.un~
	-rm -f ./Solver/*.o
	-rm -f ./Solver/.*.un~
	-rm -f ./Test/*.o
	-rm -f ./Test/.*.un~
	-rm -f ./Geometry/*.o
	-rm -f ./Geometry/.*.un~
	-rm -f ./.*.un~
	-rm -f ./*.so
	-rm -f $(EXECUTABLE)
	-rm -f $(TESTEXECUTABLE)

cleanall : clean
	-rm -f $(EXECUTABLE)
	-rm -f ./*.vtk
	-rm -f ./*.dat
